package xpn.business.fund_return.entity.notice;

import org.springframework.context.ApplicationContextException;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Objects;

@Service
public class NoticeService {
    @Resource
    private NoticeDao noticeDao;

//    @Resource
//    private FrCaseService frCaseService;

    public Notice save(Notice notice) {
        if (Objects.isNull(notice.getId())) {
            Notice exist = noticeDao.findAllByCaseId(notice.getCaseId());
            if (Objects.nonNull(exist)) {
                throw new ApplicationContextException("该表单已存在，请勿重复创建");
            }
        }
//        frCaseService.changeWriteStatus(notice.getCaseId(), CaseWriteStatus.NoticeMain);
        return noticeDao.save(notice);
    }
}
